<?php
/** Models the URL used by the API, not relevant to production environments. Used when the URL varies based on the development environment.
 * @package com\hostingreborn\api
 *
 * @author      Jon Cram <jon@hostingreborn.com>
 * @copyright   https://api.hostingreborn.com/code/copyright/
 * @license     https://api.hostingreborn.com/code/license/
 * @version     1.0
 * 
 * $Date$
 * $Revision$
 *
 *
 */
class HR_apiRequestUrl {
    
    /***************************************************************************/
    /* Attributes                                                              */
    /***************************************************************************/

    private static $domain = null;
    private static $isSecure = null;    

    const DEFAULT_DOMAIN = 'api.hostingreborn.com';
    const DEFAULT_IS_SECURE = true;

    /***************************************************************************/
    /* Constructors                                                            */
    /***************************************************************************/

    public function __construct($domain = null, $isSecure = null) {
        self::$domain = $domain;
        self::$isSecure = $isSecure;
    }

    /***************************************************************************/
    /* Public methods                                                          */
    /***************************************************************************/

    /**
     *
     * @return string
     */
    public function __toString() {
        return $this->url();
    }


    /**
     *
     * @return string
     */
    public function url() {
        $protocol = ($this->isSecure()) ? 'https' : 'http';
        return $protocol.'://'.$this->domain().'/';
    }


    /**
     *
     * @return string The API request domain
     */
    public function domain() {
        return (is_null(self::$domain)) ? self::DEFAULT_DOMAIN : self::$domain;
    }

    /**
     * Is the request URL using HTTPS?
     *
     * @return boolean
     */
    public function isSecure() {
        return (is_bool(self::$isSecure)) ? self::$isSecure : self::DEFAULT_IS_SECURE;
    }
    

    /***************************************************************************/
    /* Protected methods                                                       */
    /***************************************************************************/


    /***************************************************************************/
    /* Private methods                                                         */
    /***************************************************************************/


}

?>